
function spotClick(e) { var obj = space.getShip($(this).parent().attr("id")); obj.spotToBlock(this); }
function blockClick(e) { var obj = space.getShip($(this).parent().attr("id")); obj.blockChange(this); }
function startClick(e) { var obj = space.getShip(this.id); space.selectShip(obj); }
function keyDown(e) { space.setCode(e.keyCode, true); }
function keyUp(e) { space.setCode(e.keyCode, false); }
function rightClick(e) { space.ship.fire(e, space.zIndex); return false; }
function mouseWheel(e) { var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); space.zoom(delta); }

$(document).on('click', '.ship-spot', spotClick);
$(document).on('click', '.ship-block', blockClick);
//$(document).on('click', '.box', blockClick);
$(document).bind("contextmenu", rightClick);
//$(document).on('click', '.ship-start', startClick);
document.addEventListener('keydown', keyDown, false);
document.addEventListener('keyup', keyUp, false);
document.addEventListener('mousewheel', mouseWheel, false);

var space = new game(starShip, { id:'frigate' });

space.newShip(station, { id: 'boat1', left: 25, top: 25 });
space.newShip(station, { id: 'boat2', left: 50, top: 25 });
space.newShip(station, { id: 'boat3', left: 75, top: 25 });
space.newShip(station, { id: 'boat4', left: 25, top: 50 });
space.newShip(station, { id: 'boat5', left: 50, top: 50 });
space.newShip(station, { id: 'boat6', left: 75, top: 50 });
space.newShip(station, { id: 'boat7', left: 25, top: 75 });
space.newShip(station, { id: 'boat8', left: 50, top: 75 });
space.newShip(station, { id: 'boat9', left: 75, top: 75 });

space.loop();